// 主界面
;
define(function(require, exports, module) {
	'use strict';
	var util = require("util");
	var base = require("base");
	var dialog = require("dialog");
	var validate = require("validate");
	var css_param = require("./createPickup.css");
	var tools = require("tools");
	var leftMenu = require("../leftMenu/leftMenu");
	var databind = require("databind");
	var constant = require("constant");
    var html_bulkstockInfo1 = require("./html_bulkstockInfo1.html");//查询货物弹出框内容
    var html_commonlyInfo = require("./html_commonlyInfo.html");
    var router = require("../hash/pageRouter");
    var html_financeApplicationList = require("./html_financeApplicationList.html");
	var tfd = ['<tr class="trFinanceDetail" isNull="" style="display: table-row;">',
'									<td colspan="12">',
'										<div class="financeInfo">',
'											<div class="dataLine">',
'												<div>',
'													放款时间：<span class="data" name="loanDate"></span>',
'												</div>',
'												<div>',
'													放款金额：<span class="data" name="loanAmount"></span>',
'												</div>',
'											</div>',
'											<div class="dataLine">',
'												<div>',
'													费率（%）：<span class="data" name="intrerst"></span>',
'												</div>',
'												<div>',
'													质押率（%）：<span class="data" name="pledgeRate"></span>',
'												</div>',
'											</div>',
'											<div class="dataLine">',
'												<div>',
'													用款期限：<span class="data" name="financeDays"></span>',
'												</div>',
'												<div>',
'													货物单价：<span class="data" name="bulkstockPrice"></span>',
'												</div>',
'											</div>',
'											<div class="dataLine">',
'												<div>',
'													融资单价：<span class="data" name="financePrice"></span>',
'												</div>',
'												<div>',
'												</div>',
'											</div>',
'										</div>',
'									</td>',
'								</tr>'].join("");
    var ds;
    var pageIndex = 1,
		pageSize = 10,
		totalPageCount = 1,
		totalRecordCount = 0; //分页初始化
	var init = function() {
		router.init();
//		leftMenu.init(11);
		initEvent();
	};
	var initEvent = function() {
		//发票类型点击事件
		$("#createPickup input[name=invoiceType]").unbind("click").click(function(){
			if ($(this).val() == "0") {
				$("#createPickup .invoiceInfo1").html("");
			} else if ($(this).val() == "1"){
				var str = '<div class="dataLine">				<div class="requireInput">					公司名称:<input type="text" isNull="1" codeName="公司名称" name="invoiceEnterpriseName" placeholder="请输入公司名称"/>				</div>				<div>				</div>			</div>			<div class="dataLine">				<div class="requireInput">					纳税识别号:<input type="text" isNull="1" codeName="纳税识别号" name="invoiceTaxpayerNumber" placeholder="请输入纳税识别号"/>				</div>				<div>				</div>			</div>			<div class="dataLine">				<div class="requireInput">					地址、电话:<input type="text" isNull="1" codeName="地址、电话" name="invoiceAddress" placeholder="请输入地址、电话"/>				</div>				<div>				</div>			</div>			<div class="dataLine">				<div class="requireInput">					开户行及账号:<input type="text" isNull="1" codeName="开户行及账号" name="invoiceAccount" placeholder="请输入开户行及账号"/>				</div>				<div>				</div>			</div>';
				$("#createPickup .invoiceInfo1").html(str);
			} else if ($(this).val() == "2") {
				var str = '<div class="dataLine">				<div class="requireInput">					公司名称:<input type="text" isNull="1" codeName="公司名称" name="invoiceEnterpriseName" placeholder="请输入公司名称"/>				</div>				<div>				</div>			</div>			<div class="dataLine">				<div class="requireInput">					纳税识别号:<input type="text" isNull="1" codeName="纳税识别号" name="invoiceTaxpayerNumber" placeholder="请输入纳税识别号"/>				</div>				<div>				</div>			</div>';
				$("#createPickup .invoiceInfo1").html(str);
			}
			
		});
		
		$("#createPickup").on("change", "input[name=others]", function(){
			var $this = $(this);
			if (!isNaN($this.parents("tr").find("input[name=bulkstockAmounts]").val()) && !isNaN($this.parents("tr").find("input[name=interests]").html()) && !isNaN($this.parents("tr").find("input[name=others]").html())) {
				$this.parents("tr").find(".pickupAmount").html($this.parents("tr").find("input[name=interests]").val()*1 + $this.parents("tr").find("input[name=others]").val()*1 + $this.parents("tr").find("input[name=bulkstockAmounts]").val()*1);
				$this.parents("tr").find("input[name=pickupAmounts]").val($this.parents("tr").find("input[name=interests]").val()*1 + $this.parents("tr").find("input[name=others]").val()*1 + $this.parents("tr").find("input[name=bulkstockAmounts]").val()*1);
			}
		});
		
		$("#createPickup").on("change", "input[name=interests]", function(){
			var $this = $(this);
			if (!isNaN($this.parents("tr").find("input[name=bulkstockAmounts]").val()) && !isNaN($this.parents("tr").find("input[name=interests]").html()) && !isNaN($this.parents("tr").find("input[name=others]").html())) {
				$this.parents("tr").find(".pickupAmount").html($this.parents("tr").find("input[name=interests]").val()*1 + $this.parents("tr").find("input[name=others]").val()*1 + $this.parents("tr").find("input[name=bulkstockAmounts]").val()*1);
				$this.parents("tr").find("input[name=pickupAmounts]").val($this.parents("tr").find("input[name=interests]").val()*1 + $this.parents("tr").find("input[name=others]").val()*1 + $this.parents("tr").find("input[name=bulkstockAmounts]").val()*1);
			}
		});
		
		$("#createPickup").on("change", "input[name=bulkstockAmounts]", function(){
			var $this = $(this);
			if (!isNaN($this.parents("tr").find("input[name=bulkstockAmounts]").val()) && !isNaN($this.parents("tr").find("input[name=interests]").html()) && !isNaN($this.parents("tr").find("input[name=others]").html())) {
				$this.parents("tr").find(".pickupAmount").html($this.parents("tr").find("input[name=interests]").val()*1 + $this.parents("tr").find("input[name=others]").val()*1 + $this.parents("tr").find("input[name=bulkstockAmounts]").val()*1);
				$this.parents("tr").find("input[name=pickupAmounts]").val($this.parents("tr").find("input[name=interests]").val()*1 + $this.parents("tr").find("input[name=others]").val()*1 + $this.parents("tr").find("input[name=bulkstockAmounts]").val()*1);
			}
		});
		
		$("#createPickup .commonlyInfo").unbind("click").click(function(){
			var ii = layer.open({
			  title: '常用信息',
			  type: 1,
			  skin: 'layui-layer-rim', //加上边框
			  area: ['1000px', '650px'], //宽高
			  content: html_commonlyInfo,
			  btn: ['确定', '取消'],
			  yes: function(){
				databind.fillForm($("#createPickup .invoiceInfo"), ds[$(".html_commonlyInfo input[name=selected]:checked").parents("tr").attr("index")]);
				layer.close(ii);
			  }
			});
			
			var oData = {
				pageIndex: pageIndex,
				pageSize: pageSize,
				totalPageCount: 0
			};
			
			$(".html_commonlyInfo .search").unbind("click").click(function(){
				oData = {
					pageIndex: pageIndex,
					pageSize: pageSize,
					totalPageCount: 0,
					invoiceEnterpriseName: $(".html_commonlyInfo input[name]").val()
				};
				tools.loadList("inquireEnterpriseInvoiceInfoPageList.json", $(".html_commonlyInfo .dataBody"), $(".html_commonlyInfo .dataTpl"), oData, function(data){
					ds = data.datas;
				}, $(".html_commonlyInfo .pagerCon"));
			});
			
			tools.loadList("inquireEnterpriseInvoiceInfoPageList.json", $(".html_commonlyInfo .dataBody"), $(".html_commonlyInfo .dataTpl"), oData, function(data){
				ds = data.datas;
			}, $(".html_commonlyInfo .pagerCon"));
		});
		
		$("#createPickup select[name=enterpriseId]").html("<option value=''></option>");
		tools.loadSelectList($("#createPickup select[name=enterpriseId]"), "inquireEnterpriseList.json", "id", "name", null);
		tools.autocomplete($("#createPickup select[name=enterpriseId]"));
		
//		$("#createPickup .addFinanceApplicationInfo").unbind("click").click(function(){
//			var ii = layer.open({
//			  title: '添加融资信息',
//			  type: 1,
//			  skin: 'layui-layer-rim', //加上边框
//			  area: ['1000px', '600px'], //宽高
//			  content: html_financeApplicationList,
//			  btn: ['确定', '取消'],
//			  yes: function(){
//			  	inquireFinanceApplicationDetailByFinanceNUmber($("#createPickup .financeApplicationInfo"), $(".html_financeApplicationList .check:checked").parents("tr").attr("financeNumber"), function(){
//			  		layer.close(ii);
//			  		if ($("#createPickup .table tr").length > 1 || $("#createPickup input[name=financeIds]").val() != "") {
//						$("#createPickup select[name=enterpriseId]").attr("disabled", "disabled");
//					} else {
//						$("#createPickup select[name=enterpriseId]").removeAttr("disabled");
//					}
//			  	});
//			  }
//			});
//			tools.loadSelectList($(".html_financeApplicationList select[name=bulkstockInfoId]"), "inquireEnterpriseBulkstockList.json?enterpriseId="+$("#createPickup select[name=enterpriseId]").val(), "bulkstockInfoId", "bulkstockName", "specificationName");
//			$(".html_financeApplicationList span[name=enterpriseName]").html($("#createPickup select[name=enterpriseId] option:selected").text());
//			$(".html_financeApplicationList input[name=enterpriseId]").val($("#createPickup select[name=enterpriseId]").val());
//			
//			$(".html_financeApplicationList .search").unbind("click").click(function(){
//				databind.submitDom($(".html_financeApplicationList"), function(data){
//					juicer.register("getValueByKey", constant.getValueByKey);
//					juicer.register("formatCurrency", tools.formatCurrency);
//					var tpl = $(".html_financeApplicationList .dataTpl").html();
//					var html = juicer(tpl, data);
//					$(".html_financeApplicationList .dataBody").html(html);
//					
//				});
//			});
//		});
		
		//清空融资信息
		$("#createPickup .clearFinanceApplicationInfo").unbind("click").click(function(){
			$("#createPickup .financeApplicationInfo").find(".data, input").html("").val("");
			$("#createPickup select[name=enterpriseId]").removeAttr("disabled");
			$("#createPickup select[name=enterpriseId]").parent().find(".custom-combobox").removeClass("disabled")
		});
		
		$("#createPickup .addBulkstockInfo").unbind("click").click(function(){
			var ii = layer.open({
			  title: '添加货物信息',
			  type: 1,
			  skin: 'layui-layer-rim', //加上边框
			  area: ['1000px', '600px'], //宽高
			  content: html_bulkstockInfo1,
			  btn: ['确定', '取消'],
			  yes: function(){
			  	if ($(".html_bulkstockInfo1 .check:checked").length > 0) {
				  	var i = ($("#createPickup .table tr").length -1)/2 + 1;
				  	$.each($(".html_bulkstockInfo1 .check:checked"), function() {
				  		var $this = $(this);
				  		var tr = $(this).parents("tr").clone();
				  		tr.find(".check").parent().remove();
				  		tr.find(".index").html(i);
				  		tr.find(".showFinanceDetail").html("&nbsp;&nbsp;[+]");
				  		tr.append("<td><a href='javascript:void(0);' class='linkFinance'>关联融资</a> <a href='javascript:void(0);' class='delete'>删除</a></td>");
				  		
				  		/*tr.find(".pickupAmount").parent().append("<input type='hidden' name='pickupAmounts'/>");*/
				  		
				  		tr.find("input[name=pickupQuantitys]").parent().append(tr.find("input[name=pickupQuantitys]").val());
				  		
				  		/*tr.find("input[name=bulkstockAmounts]").parent().append(tr.find("input[name=bulkstockAmounts]").val());
				  		
				  		tr.find("input[name=interests]").parent().append(tr.find("input[name=interests]").val());*/
						tr.find(".index").after('<td><a href="javascript:void(0);" class="order_num financeNumber"><input type="hidden" isNull="1" codeName="融资" name="financeNumbers"/></a><span class="showFinanceDetail none" style="cursor: pointer;color: blue;">&nbsp;&nbsp;[+]</span></td><td class="productType"></td><td class="financeBulkstock"></td><td class="waitReceipt"></td>')
				  		$("#createPickup .table").append(tr).append(tfd);
				  		$("#createPickup .trFinanceDetail:last").hide();
				  	});
				  	layer.close(ii);
			  	} else {
					base.alert(2, "请选择货物！");
				}
			  	
			  	tools.clearNoNumAll($("#createPickup"));
			  	
			  	if ($("#createPickup .table tr").length > 2) {
					$("#createPickup select[name=enterpriseId]").attr("disabled", "disabled");
					$("#createPickup select[name=enterpriseId]").parent().find(".custom-combobox").addClass("disabled")
				} else {
					$("#createPickup select[name=enterpriseId]").removeAttr("disabled");
					$("#createPickup select[name=enterpriseId]").parent().find(".custom-combobox").removeClass("disabled")
				}
			  }
			});
			tools.loadSelectList($(".html_bulkstockInfo1 select[name=bulkstockInfoId]"), "inquireEnterpriseBulkstockList.json?enterpriseId="+$("#createPickup select[name=enterpriseId]").val(), "bulkstockInfoId", "bulkstockName", "specificationName");
			tools.loadSelectList($(".html_bulkstockInfo1 select[name=warehouseName]"), "inquireWarehouseList.json?enterpriseId=" + $("#createPickup select[name=enterpriseId]").val(), "text", "text", null);
			
//			tools.autocomplete($(".html_bulkstockInfo1 select[name=bulkstockInfoId]"));
//			tools.autocomplete($(".html_bulkstockInfo1 select[name=warehouseName]"));
			
			$(".html_bulkstockInfo1 span[name=enterpriseName]").html($("#createPickup select[name=enterpriseId] option:selected").text());
			$(".html_bulkstockInfo1 input[name=enterpriseId]").val($("#createPickup select[name=enterpriseId]").val());
			$(".html_bulkstockInfo1 select[name=productType]").val($("#createPickup input[name=productType]").val());
//			inquireBulkstockInventoryList
//			$(".createBailReturn input[name=financeId]").val(financeId);
//			tools.clearNoNumAll($(".createBailReturn"));

			$(".html_bulkstockInfo1 .search").unbind("click").click(function(){
				databind.submitDom($(".html_bulkstockInfo1"), function(data){
					juicer.register("getValueByKey", constant.getValueByKey);
					var tpl = $(".html_bulkstockInfo1 .dataTpl").html();
					var html = juicer(tpl, data);
					$(".html_bulkstockInfo1 .dataBody").html(html);
					
					$.each($(".html_bulkstockInfo1 .check"), function() {
						var $this1 = $(this).parents("tr");
						$.each($("#createPickup table tr"), function(){
							var $this2 = $(this);
							if (($this1.find("input[name=locationIds]").val() != null && $this2.find("input[name=locationIds]").val() != null) && $this1.find("input[name=locationIds]").val() == $this2.find("input[name=locationIds]").val()) {
								if (($this1.find("input[name=financeIds]").val() != null && $this2.find("input[name=financeIds]").val() != null) && $this1.find("input[name=financeIds]").val() == $this2.find("input[name=financeIds]").val()) {
									$this1.find("input").attr("disabled", "disabled");
								}
							}
						});
					});
				});
			});
			
		});
		
		$("#createPickup").on("click", ".delete", function(){
			$(this).parents("tr").remove();
			
			if ($("#createPickup .table tr").length > 2) {
				$("#createPickup select[name=enterpriseId]").attr("disabled", "disabled");
				$("#createPickup select[name=enterpriseId]").parent().find(".custom-combobox").addClass("disabled")
			} else {
				$("#createPickup select[name=enterpriseId]").removeAttr("disabled");
				$("#createPickup select[name=enterpriseId]").parent().find(".custom-combobox").removeClass("disabled")
			}
		});
		
		//提货货物关联融资
		$("#createPickup").on("click", ".linkFinance", function(){
			var $this = $(this);
			var ii = layer.open({
			  title: '添加融资信息',
			  type: 1,
			  skin: 'layui-layer-rim', //加上边框
			  area: ['1000px', '600px'], //宽高
			  content: html_financeApplicationList,
			  btn: ['确定', '取消'],
			  yes: function(){
			  	inquireFinanceApplicationDetailByFinanceNUmber($("#createPickup .financeApplicationInfo"), $(".html_financeApplicationList .check:checked").parents("tr").attr("financeNumber"), function(data){
			  		layer.close(ii);
			  		//回调
			  		$this.parents("tr").attr("financeId", data.datas[0].financeId);
			  		$this.parents("tr").find(".financeNumber").html(data.datas[0].financeNumber + '<input type="hidden" name="financeNumbers" value="'+data.datas[0].financeNumber+'" /><input type="hidden" name="financeIds" value="'+data.datas[0].financeId+'" />');
			  		$this.parents("tr").find(".productType").html(constant.getValueByKey(7, data.datas[0].productType));
			  		$this.parents("tr").find(".financeBulkstock").html(data.datas[0].bulkstocks[0].bulkstockName + "(" + data.datas[0].bulkstocks[0].specification + ")");
			  		$this.parents("tr").find(".waitReceipt").html(tools.formatCurrency(data.datas[0].totalLoanAmount - data.datas[0].totalReceivedAmount));
			  		$this.parents("tr").find(".showFinanceDetail").removeClass("none");
			  	});
			  }
			});
			tools.loadSelectList($(".html_financeApplicationList select[name=bulkstockInfoId]"), "inquireEnterpriseBulkstockList.json?enterpriseId="+$("#createPickup select[name=enterpriseId]").val(), "bulkstockInfoId", "bulkstockName", "specificationName");
			$(".html_financeApplicationList span[name=enterpriseName]").html($("#createPickup select[name=enterpriseId] option:selected").text());
			$(".html_financeApplicationList input[name=enterpriseId]").val($("#createPickup select[name=enterpriseId]").val());
			
			$(".html_financeApplicationList .search").unbind("click").click(function(){
				databind.submitDom($(".html_financeApplicationList"), function(data){
					juicer.register("getValueByKey", constant.getValueByKey);
					juicer.register("formatCurrency", tools.formatCurrency);
					var tpl = $(".html_financeApplicationList .dataTpl").html();
					var html = juicer(tpl, data);
					$(".html_financeApplicationList .dataBody").html(html);
					
				});
			});
		});
		
		tools.fileupload($("#createPickup #createPickupFilesUuid"), null, function(data){
			var str = '<span class="showFiles"><a target="_blank" class="mas" fileUuid="' + data.result.data[0].fileUuid + '" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + data.result.data[0].fileUuid + '" class="showProductIntro">' + data.result.data[0].fileName + '</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="removeFile">x</a></span>';
			$("#createPickup .addfile").before(str);
			var fs = [];
			$.each($('#createPickup .mas'), function() {
				fs.push($(this).attr("fileUuid"));
			});
			$("#createPickup input[name=filesUuid]").val(fs);
		});
		
		$("#createPickup").on("click", ".removeFile", function(){
			$(this).parents(".showFiles").remove();
			var fs = [];
			$.each($('#createPickup .mas'), function() {
				fs.push($(this).attr("fileUuid"));
			});
			$("#createPickup input[name=filesUuid]").val(fs);
		});
		
		//提交
		$("#createPickup .sure").unbind("click").click(function(){
			if ($("#createPickup table tr").length > 1) {
				databind.submitDom($("#createPickup"), function(){
					base.alert(1, "提交成功!");
					router.route("warehousePickup/wareHousePickupList.html");
				});
			} else {
				base.alert(2, "请先添加提货货物！");
			}
		});
		
		//取消
		$("#createPickup .cancel").unbind("click").click(function(){
			router.route("warehousePickup/wareHousePickupList.html");
		});
		
		//查看融资详情
		$("#createPickup").on("click", ".showFinanceDetail", function() {
			var $thisParent = $(this).parents("tr");
			var financeId = $thisParent.attr("financeId");
			//判断trFinanceDetail是否存在
			if($thisParent.next().attr("class") == "trFinanceDetail") {
				if($thisParent.next().is(":hidden")) {
					$thisParent.next().show();
					$(this).html("&nbsp;&nbsp;[-]");
				}else {
					$thisParent.next().hide();
					$(this).html("&nbsp;&nbsp;[+]");
				}
			}else {
				var strTr = '';
				strTr += '<tr class="trFinanceDetail" isNull="" style="display: ;">';
				strTr += '<td colspan="12">';
				strTr += '<div class="financeInfo">';
				strTr += '<div class="dataLine"><div>放款时间：<span class="data" name="loanDate"></span></div><div>放款金额：<span class="data" name="loanAmount"></span></div></div>';
				strTr += '<div class="dataLine"><div>费率（%）：<span class="data" name="intrerst"></span></div><div>质押率（%）：<span class="data" name="pledgeRate"></span></div></div>';
				strTr += '<div class="dataLine"><div>用款期限：<span class="data" name="financeDays"></span></div><div>货物单价：<span class="data" name="bulkstockPrice"></span></div></div>';
				strTr += '<div class="dataLine"><div>融资单价：<span class="data" name="financePrice"></span></div><div></div></div>';
				strTr += '</div>';
				strTr += '</td>';
				strTr += '</tr>';
				
				$thisParent.after(strTr);
				$(this).html("&nbsp;&nbsp;[-]");
			}
			
			if($thisParent.next().attr("isNull") != "1") {
				inquireFinanceApplicationDetail($thisParent.next(),financeId);
			}
		});
		
		$("#createPickup").on("change", "input[name=pickupQuantitys]", function(){
			var $this = $(this);
			var wi = $this.parents("tr").attr("warehouseId");
			if ($this.parents("tr").find(".sumQuantitys").html()*1 < $this.val()*1) {
				base.alert(3, "提货量不能大于监管量！");
				$this.val(0);
				$("#createPickup").find("tr[warehouseId="+wi+"]").find(".supervisionQuantitys").html($this.parents("tr").find(".sumQuantitys").html()*1 - $this.val()*1);
				return false;
			}
			$("#createPickup").find("tr[warehouseId="+wi+"]").find(".supervisionQuantitys").html($this.parents("tr").find(".sumQuantitys").html()*1 - $this.val()*1);
		});
	};
	
	//查询融资详情
	var inquireFinanceApplicationDetail = function(dom,financeId) {
		base.fnAjax({
			action: "inquireFinanceApplicationDetail.json",
			nocode: true,
			oData: {
				financeId: financeId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					var d = {};
					d.loanDate = data.datas[0].loanDate;
					d.loanAmount = tools.formatCurrency(data.datas[0].loanAmount);
					d.intrerst = data.datas[0].auditInterest;
					d.pledgeRate = (parseFloat(data.datas[0].financeAuditDetail.financeAmount)*100/parseFloat(data.datas[0].bulkstocks[0].finalPrice)).toFixed(2); 
					d.financeDays = data.datas[0].financeProductInnerDetail.financeDays;
					d.bulkstockPrice = tools.formatCurrency(data.datas[0].bulkstocks[0].bulkstockPrice);
					d.financePrice = tools.formatCurrency(data.datas[0].bulkstocks[0].financePrice);
					
					databind.fillForm(dom, d);
					
					dom.attr("isNull", "1");
				}else {
					//
				}
			}
		})
	};
	
	//查询融资详情
	var inquireFinanceApplicationDetailByFinanceNUmber = function(dom, financeNumber, callback) {
		if (financeNumber == null || financeNumber == "") {
			base.alert(3, "请输入融资编号！");
			return false;
		}
		
		base.fnAjax({
			action: "inquireFinanceApplicationDetailByFinanceNUmber.json",
			nocode: true,
			oData: {
				financeNumber: financeNumber
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
//					var d = {};
//					d.loanDate = data.datas[0].loanApplicationCreateDatetime;
//					d.loanAmount = tools.formatCurrency(data.datas[0].financeAmount);
//					d.interestRate = data.datas[0].auditInterest + "%";
//					d.financeDays = data.datas[0].financeProductInnerDetail.financeDays;
//					d.financeNumbers = data.datas[0].financeNumber;
//					d.financeIds = data.datas[0].financeId;
//					d.productType = constant.getValueByKey(7, data.datas[0].productType);
//					d.bulkstockName= data.datas[0].bulkstocks[0].bulkstockName + "("　+ data.datas[0].bulkstocks[0].specification +　")";
//					d.financeContractSerialNumber = data.datas[0].financeContractDetail.financeContractSerialNumber;
//					d.waitReceipt = data.datas[0].financeAmount-data.datas[0].totalReceivedAmount;
//					d.deadLine = tools.addDate(data.datas[0].loanApplicationCreateDatetime, data.datas[0].financeProductInnerDetail.financeDays);
//					
//					databind.fillForm(dom, d);
					callback(data);
				}else {
					base.alert(3, data.message);
				}
			}
		})
	};
	
	return {
		init: init
	};
});